package com.qf.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.Arrays;
import java.util.List;

/**
 * @Description: 公用常量
 * @Data: 2022/9/6 10:41
 * @Pacakge: com.qf.controller
 * @ClassName: ExceptionController
 * @Author: fan
 */
@Controller
public class ExceptionController {
    @RequestMapping("exception")
    public String exceptionInfo(){
        System.out.println("exception");
        String str = null;
        str.length();
        return "success";
    }
    //越界异常
    @RequestMapping("exception01")
    public String exception01(){
        System.out.println("exception");
        List<Integer> integers = Arrays.asList(1, 2, 3, 4);
        Integer integer = integers.get(100);
        return "success";
    }
   /* @ExceptionHandler(RuntimeException.class)
    public ModelAndView nullPo(Exception ex){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/error/error");
        modelAndView.addObject("messages",ex.toString());
        return modelAndView;
    }
    @ExceptionHandler(ArrayIndexOutOfBoundsException.class)
    public ModelAndView indexPo(Exception ex){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/error/error");
        modelAndView.addObject("messages",ex.toString());
        return modelAndView;
    }*/
}
